//compilation erro
#include "stdio.h"
#include "string.h"

#define off 1000

int a, b, c, d, i, j, k, t, n, x2, y2, x[4], y[4], xoff, yoff;
int pin[4][100000][2];
unsigned char sok[2001][2001], ok;


int main(){
	//freopen("in.txt","r",stdin);
	scanf("%d", &t);
	
	while(t--){
		scanf("%d", &n);
		memset(sok,1,4004001*sizeof(unsigned char) );
		for(j=0;j<4;++j)x[j]=y[j]=2000000000;
		x2=y2=2000000000;
		
		for(i=0;i<n;++i){
			scanf("%d%d", &a, &b);
			for(j=0;j<4;++j){
				k= a;
				a= -1*b;
				b= k;
				pin[j][i][0]=a;
				pin[j][i][1]=b;
				if(a<x[j]){
					x[j]=a;
					y[j]=b;
				}
				else if( (a==x[j]) && (b<y[j]) ){
					x[j]=a;
					y[j]=b;
				}
			}
		}	
		for(i=0;i<n;++i){
			scanf("%d%d", &a, &b);
			a+=off;
			b+=off;
			sok[a][b]=0;//not empty
			if(a<x2){
				x2=a;
				y2=b;
			}
			else if( (a==x2) && (b<y2) ){
				x2=a;
				y2=b;
			}
		}
		
		for(i=0;i<4;++i){
			ok=1;
			xoff = x2-x[i];
			yoff = y2-y[i];
			for(j=0;(j<n)&&ok;++j){
				a=pin[i][j][0]+xoff;
				b=pin[i][j][1]+yoff;
				if(a<2001&&b<2001){
					if(sok[a][b])ok=0;
				}
			}
			if(ok){
				printf("MATCHED\n");
				break;
			}
		}
		if(!ok)printf("NOT MATCHED\n");
	}
	return 0;
}
